package com.javaAPI.demo6;


import java.util.function.DoubleToIntFunction;

public class Test {
    public static void main(String[] args) {

//        Animal animal = new CatImpl();
        Animal animal = new DogImpl();

        /**
         * 强制转换在编译阶段不报错
         * 运行阶段强制转换可能会报错  ClassCastException
         */
//        DogImpl dogImpl = (DogImpl) cat;
        DogImpl dog = new DogImpl();
        if (animal instanceof DogImpl) {
            System.out.println("类型相同，可以强转");
            DogImpl dogImpl = (DogImpl) animal;
        }else {
            System.out.println("类型不同，不可强转");
        }
    }
}
